import { URLSearchParams } from 'url'

let exportCount = 0

const mockData: Record<string, () => any> = {
  '/api/plugin/export': () => [
    {
      index: 0,
      name: 'test',
      desc: null,
      add_time: 1610557429,
      up_time: 1610557429,
      list: [
        {
          query_path: {
            path: '/deleteMethod',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 45,
          method: 'DELETE',
          catid: 18,
          title: 'DELETE 方法',
          path: '/deleteMethod',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '5cbdd2e993bc6574a2de33e5',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          markdown: '',
          desc: '',
          res_body: '{"type":"object","title":"empty object","properties":{}}',
          req_body_type: 'json',
          req_body_other:
            '{"type":"object","title":"empty object","properties":{"id":{"type":"string","description":"ID"}},"required":["id"]}',
          uid: 11,
          add_time: 1610557429,
          up_time: 1610557429,
          __v: 0,
        },
        {
          query_path: {
            path: '/getMethod',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 51,
          method: 'GET',
          catid: 18,
          title: 'GET 方法',
          path: '/getMethod',
          project_id: 11,
          res_body_type: 'json',
          req_body_form: [],
          req_params: [],
          req_headers: [],
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5cbdd1c293bc6574a2de33db',
              name: 'x',
              example: '100',
              desc: 'X 值',
            },
            {
              required: '0',
              type: 'string',
              _id: '5cbdd1c293bc6574a2de33da',
              name: 'y',
              example: '2',
              desc: 'Y 值',
            },
          ],
          markdown: '',
          desc: '',
          res_body:
            '{"type":"object","title":"empty object","properties":{"result":{"type":"number","description":"结果"}},"required":["result"]}',
          uid: 11,
          add_time: 1610557429,
          up_time: 1610557429,
          __v: 0,
        },
        {
          query_path: {
            path: '/json5Response',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 57,
          method: 'GET',
          catid: 18,
          title: 'JSON5 响应',
          path: '/json5Response',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [],
          req_body_form: [],
          markdown: '',
          desc: '',
          res_body:
            '{\n    /** 注释 */\n    "id": 1,\n    "age": "@float",\n    "name": "@name"\n}',
          uid: 11,
          add_time: 1610557429,
          up_time: 1610557429,
          __v: 0,
        },
        {
          query_path: {
            path: '/json5Request',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 63,
          method: 'POST',
          catid: 18,
          title: 'JSON5 请求',
          path: '/json5Request',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '5f30d27c836a360dd0cfa97b',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          req_body_other:
            '{\n  "id": 1,\n  "name": "方剑成",\n  "likes": [\n    "photo",\n    2\n  ],\n  // 嵌套的\n  "nest": {\n      "x": 1,\n      "y": {"z":"2"}\n  }\n}',
          markdown: '',
          desc: '',
          res_body: '',
          req_body_type: 'json',
          uid: 11,
          add_time: 1610557429,
          up_time: 1610557429,
          __v: 0,
        },
        {
          query_path: {
            path: '/postMethod',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 69,
          method: 'POST',
          catid: 18,
          title: 'POST 方法',
          path: '/postMethod',
          project_id: 11,
          res_body_type: 'json',
          req_body_form: [],
          req_params: [],
          req_headers: [
            {
              required: '1',
              _id: '5cbdd24b93bc6574a2de33dd',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_query: [],
          req_body_other:
            '{"type":"object","title":"empty object","properties":{"page":{"type":"number","description":"页码"},"limit":{"type":"number","description":"每页数量"},"keyword":{"type":"string","description":"关键词"}},"required":["page","limit"]}',
          markdown: '**备注。。。**\n\n`额鹅鹅鹅`',
          desc: '<p><strong>备注。。。</strong></p>\n<p><code data-backticks="1">额鹅鹅鹅</code></p>\n',
          res_body:
            '{"type":"object","title":"empty object","properties":{"list":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string","description":"姓名"}},"required":["name"]},"description":"列表"}},"required":["list"]}',
          req_body_type: 'json',
          uid: 11,
          add_time: 1610557429,
          up_time: 1610557429,
          __v: 0,
        },
        {
          query_path: {
            path: '/putMethod',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 75,
          method: 'PUT',
          catid: 18,
          title: 'PUT 方法',
          path: '/putMethod',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5cbdd2b793bc6574a2de33e2',
              name: 'id',
              desc: '',
            },
            {
              required: '0',
              type: 'string',
              _id: '5cbdd2b793bc6574a2de33e1',
              name: 'namre',
              example: '',
              desc: '',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '5cbdd2b793bc6574a2de33e3',
              name: 'Content-Type',
              value: 'application/x-www-form-urlencoded',
            },
          ],
          req_body_form: [
            {
              required: '1',
              _id: '5cbdd2b793bc6574a2de33e4',
              name: 'x',
              type: 'text',
              example: '9',
              desc: 'X 值',
            },
          ],
          markdown: '',
          desc: '',
          res_body:
            '{"type":"object","title":"empty object","properties":{"err":{"type":"number","description":"错误"},"msg":{"type":"string","description":"错误详情"},"data":{"type":"object","properties":{},"description":"数据"}},"required":["err","msg"]}',
          req_body_type: 'form',
          uid: 11,
          add_time: 1610557429,
          up_time: 1610557429,
          __v: 0,
        },
        {
          query_path: {
            path: '/dataKeyExample',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 81,
          method: 'PUT',
          catid: 18,
          title: 'dataKey 例子',
          path: '/dataKeyExample',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5cbdd3e093bc6574a2de33ec',
              name: 'id',
              desc: '',
            },
            {
              required: '0',
              type: 'string',
              _id: '5cbdd3e093bc6574a2de33eb',
              name: 'namre',
              example: '',
              desc: '',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '5cbdd3e093bc6574a2de33ed',
              name: 'Content-Type',
              value: 'application/x-www-form-urlencoded',
            },
          ],
          req_body_form: [
            {
              required: '1',
              _id: '5cbdd3e093bc6574a2de33ee',
              name: 'x',
              type: 'text',
              example: '9',
              desc: 'X 值',
            },
          ],
          markdown: '',
          desc: '',
          res_body:
            '{"type":"object","title":"empty object","properties":{"err":{"type":"number","description":"错误"},"msg":{"type":"string","description":"错误详情"},"data":{"type":"object","properties":{"success":{"type":"boolean","description":"成功啦"}},"description":"数据","required":["success"]}},"required":["err","msg"]}',
          req_body_type: 'form',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/dataKey/deep',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1167,
          method: 'GET',
          catid: 18,
          title: 'dataKey 深度路径',
          path: '/dataKey/deep',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1626489315,
          up_time: 1626489548,
          req_query: [],
          req_headers: [],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body:
            '{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"err":{"type":"number"},"container":{"type":"object","properties":{"data":{"type":"object","properties":{"realData":{"type":"string","description":"真数据"}},"required":["realData"]}},"required":["data"]}},"required":["err","container"]}',
        },
        {
          query_path: {
            path: '/get/only_post_form_data',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1345,
          method: 'GET',
          catid: 18,
          title: 'fix: 仅 POST 类接口处理表单数据',
          path: '/get/only_post_form_data',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1632493812,
          up_time: 1632493928,
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '614de1689b660993e30c509c',
              name: 'query_id',
              desc: 'id',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '614de1689b6609d0ae0c509d',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body: '',
          req_body_type: 'json',
          req_body_other:
            '{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{"post_json_id":{"type":"number"}},"required":["post_json_id"]}',
        },
        {
          query_path: {
            path: '/upload',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 87,
          method: 'POST',
          catid: 18,
          title: '文件',
          path: '/upload',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '5e4ddd6d857008453968175a',
              name: 'Content-Type',
              value: 'multipart/form-data',
            },
          ],
          req_body_form: [
            {
              required: '1',
              _id: '5e4ddd6d8570083c9568175c',
              name: 'file',
              type: 'file',
              desc: '文件',
            },
            {
              required: '1',
              _id: '5e4ddd6d8570081bfd68175b',
              name: 'name',
              type: 'text',
              example: '',
              desc: '名称',
            },
          ],
          desc: '',
          markdown: '',
          req_body_type: 'form',
          res_body: '{"type":"object","title":"empty object","properties":{}}',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/test',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 93,
          method: 'POST',
          catid: 18,
          title: '查询参数+对象',
          path: '/test',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5fdf6bed71df65ad10036c29',
              name: 'cid',
              desc: 'cid',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '5fdf6bed71df659a52036c2a',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          req_body_other:
            '{"type":"object","title":"empty object","properties":{"K1":{"type":"string","description":"键1"},"K2":{"type":"number","description":"键2"}},"required":["K1"]}',
          markdown: '',
          desc: '',
          res_body: '',
          req_body_type: 'json',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/noResponseData',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 99,
          method: 'GET',
          catid: 18,
          title: '没返回数据',
          path: '/noResponseData',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [],
          req_body_form: [],
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/emptyResponse',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 105,
          method: 'POST',
          catid: 18,
          title: '空返回数据',
          path: '/emptyResponse',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '5cbdd0f793bc6574a2de33d9',
              name: 'Content-Type',
              value: 'application/x-www-form-urlencoded',
            },
          ],
          req_body_form: [],
          markdown: '',
          desc: '',
          res_body: '{"type":"object","title":"empty object","properties":{}}',
          req_body_type: 'form',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/headers',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1087,
          method: 'GET',
          catid: 18,
          title: '请求头',
          path: '/headers',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1619432942,
          up_time: 1619432971,
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '6086960b1e85e5535e1f812b',
              name: 'Authorization',
              value: 'dddddd',
            },
            {
              required: '1',
              _id: '6086960b1e85e5508d1f812a',
              name: 'ffff',
              example: '',
              desc: '',
            },
            {
              required: '1',
              _id: '6086960b1e85e539231f8129',
              name: 'Cookie',
              value: 'x=1',
              example: '',
              desc: '',
            },
          ],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body: '{"type":"object","title":"title","properties":{}}',
        },
        {
          query_path: {
            path: '/path/:id/hello/:name/:pass/{avatar}/:test',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'var',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 111,
          method: 'POST',
          catid: 18,
          title: '路径参数',
          path: '/path/:id/hello/:name/:pass/{avatar}/:test',
          project_id: 11,
          req_params: [
            {
              type: 'string',
              _id: '5d80d7103667dc0844b411d7',
              name: 'id',
              example: 'ID',
              desc: '23',
            },
            {
              type: 'string',
              _id: '5d80d7103667dc0844b411d6',
              name: 'name',
              desc: '',
            },
            {
              type: 'string',
              _id: '5d80d7103667dc0844b411d5',
              name: 'pass',
              desc: '',
            },
            {
              type: 'string',
              _id: '5d80d7103667dc0844b411d4',
              name: 'test',
              desc: '',
            },
            {
              type: 'string',
              _id: '5d80d7103667dc0844b411d3',
              name: 'avatar',
              desc: '',
            },
          ],
          res_body_type: 'json',
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '5d80d7103667dc0844b411d8',
              name: 'Content-Type',
              value: 'application/x-www-form-urlencoded',
            },
          ],
          req_body_form: [],
          markdown: '',
          desc: '',
          res_body: '',
          req_body_type: 'form',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/test/{id}/:hihihi',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'var',
          req_body_is_json_schema: true,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 117,
          method: 'POST',
          catid: 18,
          title: '路径参数+对象',
          path: '/test/{id}/:hihihi',
          project_id: 11,
          req_params: [
            {
              type: 'string',
              _id: '5d80e91e3667dc0844b411df',
              name: 'hihihi',
              example: 'demo',
              desc: '嗨咯',
            },
            {
              type: 'string',
              _id: '5d80e91e3667dc0844b411de',
              name: 'id',
              example: '110',
              desc: 'ID',
            },
          ],
          res_body_type: 'json',
          req_query: [],
          req_headers: [
            {
              required: '1',
              _id: '5d80e91e3667dc0844b411e0',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          req_body_other:
            '{"type":"object","title":"empty object","properties":{"K1":{"type":"string","description":"键1"},"K2":{"type":"number","description":"键2"}},"required":["K1"]}',
          markdown: '',
          desc: '',
          res_body: '',
          req_body_type: 'json',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/test/{id}/:hihihi_1608478638207',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'var',
          req_body_is_json_schema: true,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 123,
          method: 'POST',
          catid: 18,
          title: '路径参数+查询参数+对象',
          path: '/test/{id}/:hihihi_1608478638207',
          project_id: 11,
          req_params: [
            {
              type: 'string',
              _id: '5fdf6fcb71df657be3036c36',
              name: 'hihihi',
              example: 'demo',
              desc: '嗨咯',
            },
            {
              type: 'string',
              _id: '5fdf6fcb71df65b48f036c35',
              name: 'id',
              example: '110',
              desc: 'ID',
            },
            {
              type: 'string',
              _id: '5fdf6fcb71df652a3b036c34',
              name: 'hihihi_1608478638207',
              desc: '',
            },
          ],
          res_body_type: 'json',
          req_query: [
            {
              required: '0',
              type: 'string',
              _id: '5fdf6fcb71df655a14036c37',
              name: 'query',
              desc: '22222',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '5fdf6fcb71df65d64f036c38',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          req_body_other:
            '{"type":"object","title":"empty object","properties":{"K1":{"type":"string","description":"键1"},"K2":{"type":"number","description":"键2"}},"required":["K1"]}',
          markdown: '',
          desc: '',
          res_body: '',
          req_body_type: 'json',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/user/:id/avatar',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'var',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1137,
          method: 'GET',
          catid: 18,
          title: '路径参数、查询参数类型',
          path: '/user/:id/avatar',
          project_id: 11,
          req_params: [
            {
              type: 'number',
              _id: '60a6257ef009d420d84d4341',
              name: 'id',
              desc: 'ID',
            },
          ],
          res_body_type: 'json',
          uid: 11,
          add_time: 1621501275,
          up_time: 1621501310,
          req_query: [
            {
              required: '1',
              type: 'number',
              _id: '60a6257ef009d449004d4343',
              name: 'size',
              desc: '大小',
            },
            {
              required: '1',
              type: 'string',
              _id: '60a6257ef009d4e63a4d4342',
              name: 'format',
              example: '',
              desc: '格式',
            },
          ],
          req_headers: [],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body: '',
        },
        {
          query_path: {
            path: '/rawResponse',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 129,
          method: 'GET',
          catid: 18,
          title: '返回 raw',
          path: '/rawResponse',
          project_id: 11,
          req_params: [],
          res_body_type: 'raw',
          req_query: [],
          req_headers: [],
          req_body_form: [],
          markdown: '',
          desc: '',
          res_body: '',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
      ],
    },
    {
      index: 0,
      name: 'test2',
      desc: null,
      add_time: 1610557429,
      up_time: 1610557429,
      list: [
        {
          query_path: {
            path: '/get2',
            params: [],
          },
          edit_uid: 0,
          status: 'done',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: ['2期', '梦想城'],
          _id: 135,
          method: 'GET',
          catid: 20,
          title: 'hello',
          path: '/get2',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [],
          req_body_form: [],
          markdown: '',
          desc: '',
          res_body:
            '{"type":"object","title":"empty object","properties":{"msg":{"type":"string"}},"required":["msg"]}',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/mockjs_json5',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1830,
          method: 'GET',
          catid: 20,
          title: 'mockjs+json5',
          path: '/mockjs_json5',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1644917567,
          up_time: 1644917600,
          req_query: [],
          req_headers: [],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body:
            '{\n    "code": 200,\n    "data|1-10": [\n        {\n            "id": "@id", // id\n            "name": "@cname", // 名字\n            "template|1-10": "*", // 模板\n            "string|3": "***", // 遍历三次\n            "number|1-100": 200,\n            "boolean": "@boolean",\n            "image": "@image"\n        }\n    ]\n}',
        },
        {
          query_path: {
            path: '/mockjs2',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: false,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1831,
          method: 'GET',
          catid: 20,
          title: 'mockjs2',
          path: '/mockjs2',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1645001853,
          up_time: 1645001866,
          req_query: [],
          req_headers: [],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body:
            '{\n   "pageNo": 1,\n   "pageSize": 5,\n   "count": 16,\n   "first": 1,\n   "last": 1,\n   "prev": 1,\n   "next": 1,\n   "firstPage": true,\n   "lastPage": true,\n   "length": 8,\n   "slider": 1,\n   "orderBy": "",\n   "funcName": "page",\n   "funcParam": "",\n   "message": "",\n   "html": "",\n   "totalPage": 1,\n   "notCount": false,\n   "maxResults": 5,\n   "disabled": false,\n   "firstResult": 0\n}',
        },
        {
          query_path: {
            path: '/ref_type',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: false,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1832,
          method: 'GET',
          catid: 20,
          title: '类型引用',
          path: '/ref_type',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1645844560,
          up_time: 1647247632,
          req_query: [],
          req_headers: [],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body:
            '{"type":"object","title":"title","properties":{"list":{"type":"array","items":{"type":"object","properties":{"label":{"type":"string"},"value":{"type":"string"},"children":{"type":"array","items":{"type":"object","properties":{}},"title":"&.."},"id":{"type":"number"},"parent":{"type":"string","title":"&."}},"required":["label","value","id"]}},"list2":{"type":"array","items":{"type":"object","properties":{}},"title":"&./list"},"obj":{"type":"array","items":{"type":"object","properties":{"list3":{"type":"array","items":{"type":"object","properties":{}},"title":"&/list"},"name":{"type":"number"},"name2":{"type":"string","title":"&./name"},"id2":{"type":"string","title":"&/list/0/id"}},"required":["list3","name","name2","id2"]}},"root":{"type":"string","title":"&/"}},"required":["list","list2","obj","root"]}',
        },
        {
          query_path: {
            path: '/default_value',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 1829,
          method: 'GET',
          catid: 20,
          title: '默认值',
          path: '/default_value',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          uid: 11,
          add_time: 1642140768,
          up_time: 1642140816,
          req_query: [],
          req_headers: [],
          req_body_form: [],
          __v: 0,
          desc: '',
          markdown: '',
          res_body:
            '{"type":"object","title":"title","properties":{"id":{"type":"number","default":"67"}},"required":["id"]}',
        },
      ],
    },
    {
      index: 0,
      name: 'issues',
      desc: null,
      add_time: 1610557429,
      up_time: 1610557429,
      list: [
        {
          query_path: {
            path: '/issue-17/picture_3d_detail',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 141,
          method: 'GET',
          catid: 22,
          title: '17: path 含有数字时，大小写出现错误',
          path: '/issue-17/picture_3d_detail',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [],
          req_headers: [],
          req_body_form: [],
          desc: '<p><a href="https://github.com/fjc0k/yapi-to-typescript/issues/17">https://github.com/fjc0k/yapi-to-typescript/issues/17</a></p>\n',
          markdown:
            '[https://github.com/fjc0k/yapi-to-typescript/issues/17](https://github.com/fjc0k/yapi-to-typescript/issues/17)',
          res_body: '{"type":"object","title":"empty object","properties":{}}',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/28/get',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 147,
          method: 'GET',
          catid: 22,
          title: '28: 字段名称含空格 GET',
          path: '/28/get',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5eba060b3a90e2c457f435a8',
              name: '   a',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba060b3a90e2a675f435a7',
              name: ' b',
              example: '',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba060b3a90e23035f435a6',
              name: 'c ',
              example: '',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba060b3a90e24fc3f435a5',
              name: '    d    e   ',
              example: '',
              desc: '',
            },
          ],
          req_headers: [],
          req_body_form: [],
          desc: '',
          markdown: '',
          res_body: '{"type":"object","title":"title","properties":{}}',
          uid: 11,
          add_time: 1610557430,
          up_time: 1610557430,
          __v: 0,
        },
        {
          query_path: {
            path: '/28/post/form',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 153,
          method: 'POST',
          catid: 22,
          title: '28: 字段名称含空格 POST form',
          path: '/28/post/form',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5eba069e3a90e203f9f435b9',
              name: '   a',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba069e3a90e2235af435b8',
              name: ' b',
              example: '',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba069e3a90e24aabf435b7',
              name: 'c ',
              example: '',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba069e3a90e2c36ef435b6',
              name: '    d    e   ',
              example: '',
              desc: '',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '5eba069e3a90e2ea69f435ba',
              name: 'Content-Type',
              value: 'application/x-www-form-urlencoded',
            },
          ],
          req_body_form: [
            {
              required: '1',
              _id: '5eba069e3a90e22bd5f435be',
              name: 'a ',
              type: 'text',
            },
            {
              required: '1',
              _id: '5eba069e3a90e27bdef435bd',
              name: '  b  ',
              type: 'text',
              example: '',
              desc: '',
            },
            {
              required: '1',
              _id: '5eba069e3a90e2697bf435bc',
              name: ' c',
              type: 'text',
              example: '',
              desc: '',
            },
            {
              required: '1',
              _id: '5eba069e3a90e2269ef435bb',
              name: 'd   e  ',
              type: 'text',
              example: '',
              desc: '',
            },
          ],
          desc: '',
          markdown: '',
          res_body: '{"type":"object","title":"title","properties":{}}',
          req_body_type: 'form',
          uid: 11,
          add_time: 1610557431,
          up_time: 1610557431,
          __v: 0,
        },
        {
          query_path: {
            path: '/28/post/json',
            params: [],
          },
          edit_uid: 0,
          status: 'undone',
          type: 'static',
          req_body_is_json_schema: true,
          res_body_is_json_schema: true,
          api_opened: false,
          index: 0,
          tag: [],
          _id: 159,
          method: 'POST',
          catid: 22,
          title: '28: 字段名称含空格 POST json',
          path: '/28/post/json',
          project_id: 11,
          req_params: [],
          res_body_type: 'json',
          req_query: [
            {
              required: '1',
              type: 'string',
              _id: '5eba07063a90e2a0aff435cb',
              name: '   a',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba07063a90e25183f435ca',
              name: ' b',
              example: '',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba07063a90e22770f435c9',
              name: 'c ',
              example: '',
              desc: '',
            },
            {
              required: '1',
              type: 'string',
              _id: '5eba07063a90e2377cf435c8',
              name: '    d    e   ',
              example: '',
              desc: '',
            },
          ],
          req_headers: [
            {
              required: '1',
              _id: '5eba07063a90e29219f435cc',
              name: 'Content-Type',
              value: 'application/json',
            },
          ],
          req_body_form: [],
          desc: '',
          markdown: '',
          res_body:
            '{"$schema":"http://json-schema.org/draft-04/schema#","type":"object","properties":{" a":{"type":"number"},"b  ":{"type":"string"},"c":{"type":"object","properties":{"d  ":{"type":"string"}}}}}',
          req_body_type: 'json',
          req_body_other:
            '{"type":"object","title":"title","properties":{"  a":{"type":"string"},"b  ":{"type":"string"},"c   d ":{"type":"string"},"e":{"type":"object","properties":{"f ":{"type":"string"}},"required":["f "]}},"required":["  a","b  ","c   d ","e"]}',
          uid: 11,
          add_time: 1610557431,
          up_time: 1610557431,
          __v: 0,
        },
      ],
    },
  ],
  '/api/interface/getCatMenu': () => ({
    errcode: 0,
    errmsg: '成功！',
    data: [
      {
        index: 0,
        _id: 12,
        name: '公共分类',
        project_id: 11,
        desc: '公共分类',
        uid: 11,
        add_time: 1610557167,
        up_time: 1610557167,
        __v: 0,
      },
      {
        index: 0,
        _id: 18,
        name: 'test',
        project_id: 11,
        desc: null,
        uid: 11,
        add_time: 1610557429,
        up_time: 1610557429,
        __v: 0,
      },
      {
        index: 0,
        _id: 20,
        name: 'test2',
        project_id: 11,
        desc: null,
        uid: 11,
        add_time: 1610557429,
        up_time: 1610557429,
        __v: 0,
      },
      {
        index: 0,
        _id: 22,
        name: 'issues',
        project_id: 11,
        desc: null,
        uid: 11,
        add_time: 1610557429,
        up_time: 1610557429,
        __v: 0,
      },
    ],
  }),
  '/api/project/get': () => ({
    errcode: 0,
    errmsg: '成功！',
    data: {
      switch_notice: true,
      is_mock_open: false,
      is_sync_open: false,
      strice: false,
      is_json5: false,
      _id: 32,
      name: 'test',
      basepath: '',
      project_type: 'private',
      uid: 11,
      group_id: 11,
      icon: 'code-o',
      color: 'yellow',
      add_time: 1554276482,
      up_time: 1555516501,
      env: [
        {
          header: [],
          global: [],
          _id: '5cb74c5593bc6574a2de33cc',
          name: 'production',
          domain: 'http://prod.com/',
        },
        {
          header: [],
          global: [],
          _id: '5ca460829301e2047a07b652',
          name: 'local',
          domain: 'http://127.0.0.1',
        },
      ],
      tag: [],
      desc: '44555666666',
      cat: [],
      role: 'admin',
    },
  }),
  '/v2/swagger.json': () => ({
    swagger: '2.0',
    info: {
      description:
        'This is a sample server Petstore server.  You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/).  For this sample, you can use the api key `special-key` to test the authorization filters.',
      version: '1.0.5',
      title: 'Swagger Petstore',
      termsOfService: 'http://swagger.io/terms/',
      contact: { email: 'apiteam@swagger.io' },
      license: {
        name: 'Apache 2.0',
        url: 'http://www.apache.org/licenses/LICENSE-2.0.html',
      },
    },
    host: 'petstore.swagger.io',
    basePath: '/v2',
    tags: [
      {
        name: 'pet',
        description: 'Everything about your Pets',
        externalDocs: {
          description: 'Find out more',
          url: 'http://swagger.io',
        },
      },
      { name: 'store', description: 'Access to Petstore orders' },
      {
        name: 'user',
        description: 'Operations about user',
        externalDocs: {
          description: 'Find out more about our store',
          url: 'http://swagger.io',
        },
      },
    ],
    schemes: ['https', 'http'],
    paths: {
      '/pet/{petId}/uploadImage': {
        post: {
          tags: ['pet'],
          summary: 'uploads an image',
          description: '',
          operationId: 'uploadFile',
          consumes: ['multipart/form-data'],
          produces: ['application/json'],
          parameters: [
            {
              name: 'petId',
              in: 'path',
              description: 'ID of pet to update',
              required: true,
              type: 'integer',
              format: 'int64',
            },
            {
              name: 'additionalMetadata',
              in: 'formData',
              description: 'Additional data to pass to server',
              required: false,
              type: 'string',
            },
            {
              name: 'file',
              in: 'formData',
              description: 'file to upload',
              required: false,
              type: 'file',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { $ref: '#/definitions/ApiResponse' },
            },
          },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
        },
      },
      '/pet': {
        post: {
          tags: ['pet'],
          summary: 'Add a new pet to the store',
          description: '',
          operationId: 'addPet',
          consumes: ['application/json', 'application/xml'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              in: 'body',
              name: 'body',
              description: 'Pet object that needs to be added to the store',
              required: true,
              schema: { $ref: '#/definitions/Pet' },
            },
          ],
          responses: { '405': { description: 'Invalid input' } },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
        },
        put: {
          tags: ['pet'],
          summary: 'Update an existing pet',
          description: '',
          operationId: 'updatePet',
          consumes: ['application/json', 'application/xml'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              in: 'body',
              name: 'body',
              description: 'Pet object that needs to be added to the store',
              required: true,
              schema: { $ref: '#/definitions/Pet' },
            },
          ],
          responses: {
            '400': { description: 'Invalid ID supplied' },
            '404': { description: 'Pet not found' },
            '405': { description: 'Validation exception' },
          },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
        },
      },
      '/pet/findByStatus': {
        get: {
          tags: ['pet'],
          summary: 'Finds Pets by status',
          description:
            'Multiple status values can be provided with comma separated strings',
          operationId: 'findPetsByStatus',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'status',
              in: 'query',
              description:
                'Status values that need to be considered for filter',
              required: true,
              type: 'array',
              items: {
                type: 'string',
                enum: ['available', 'pending', 'sold'],
                default: 'available',
              },
              collectionFormat: 'multi',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { type: 'array', items: { $ref: '#/definitions/Pet' } },
            },
            '400': { description: 'Invalid status value' },
          },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
        },
      },
      '/pet/findByTags': {
        get: {
          tags: ['pet'],
          summary: 'Finds Pets by tags',
          description:
            'Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.',
          operationId: 'findPetsByTags',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'tags',
              in: 'query',
              description: 'Tags to filter by',
              required: true,
              type: 'array',
              items: { type: 'string' },
              collectionFormat: 'multi',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { type: 'array', items: { $ref: '#/definitions/Pet' } },
            },
            '400': { description: 'Invalid tag value' },
          },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
          deprecated: true,
        },
      },
      '/pet/{petId}': {
        get: {
          tags: ['pet'],
          summary: 'Find pet by ID',
          description: 'Returns a single pet',
          operationId: 'getPetById',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'petId',
              in: 'path',
              description: 'ID of pet to return',
              required: true,
              type: 'integer',
              format: 'int64',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { $ref: '#/definitions/Pet' },
            },
            '400': { description: 'Invalid ID supplied' },
            '404': { description: 'Pet not found' },
          },
          security: [{ api_key: [] }],
        },
        post: {
          tags: ['pet'],
          summary: 'Updates a pet in the store with form data',
          description: '',
          operationId: 'updatePetWithForm',
          consumes: ['application/x-www-form-urlencoded'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'petId',
              in: 'path',
              description: 'ID of pet that needs to be updated',
              required: true,
              type: 'integer',
              format: 'int64',
            },
            {
              name: 'name',
              in: 'formData',
              description: 'Updated name of the pet',
              required: false,
              type: 'string',
            },
            {
              name: 'status',
              in: 'formData',
              description: 'Updated status of the pet',
              required: false,
              type: 'string',
            },
          ],
          responses: { '405': { description: 'Invalid input' } },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
        },
        delete: {
          tags: ['pet'],
          summary: 'Deletes a pet',
          description: '',
          operationId: 'deletePet',
          produces: ['application/json', 'application/xml'],
          parameters: [
            { name: 'api_key', in: 'header', required: false, type: 'string' },
            {
              name: 'petId',
              in: 'path',
              description: 'Pet id to delete',
              required: true,
              type: 'integer',
              format: 'int64',
            },
          ],
          responses: {
            '400': { description: 'Invalid ID supplied' },
            '404': { description: 'Pet not found' },
          },
          security: [{ petstore_auth: ['write:pets', 'read:pets'] }],
        },
      },
      '/store/order': {
        post: {
          tags: ['store'],
          summary: 'Place an order for a pet',
          description: '',
          operationId: 'placeOrder',
          consumes: ['application/json'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              in: 'body',
              name: 'body',
              description: 'order placed for purchasing the pet',
              required: true,
              schema: { $ref: '#/definitions/Order' },
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { $ref: '#/definitions/Order' },
            },
            '400': { description: 'Invalid Order' },
          },
        },
      },
      '/store/order/{orderId}': {
        get: {
          tags: ['store'],
          summary: 'Find purchase order by ID',
          description:
            'For valid response try integer IDs with value >= 1 and <= 10. Other values will generated exceptions',
          operationId: 'getOrderById',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'orderId',
              in: 'path',
              description: 'ID of pet that needs to be fetched',
              required: true,
              type: 'integer',
              maximum: 10,
              minimum: 1,
              format: 'int64',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { $ref: '#/definitions/Order' },
            },
            '400': { description: 'Invalid ID supplied' },
            '404': { description: 'Order not found' },
          },
        },
        delete: {
          tags: ['store'],
          summary: 'Delete purchase order by ID',
          description:
            'For valid response try integer IDs with positive integer value. Negative or non-integer values will generate API errors',
          operationId: 'deleteOrder',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'orderId',
              in: 'path',
              description: 'ID of the order that needs to be deleted',
              required: true,
              type: 'integer',
              minimum: 1,
              format: 'int64',
            },
          ],
          responses: {
            '400': { description: 'Invalid ID supplied' },
            '404': { description: 'Order not found' },
          },
        },
      },
      '/store/inventory': {
        get: {
          tags: ['store'],
          summary: 'Returns pet inventories by status',
          description: 'Returns a map of status codes to quantities',
          operationId: 'getInventory',
          produces: ['application/json'],
          parameters: [],
          responses: {
            '200': {
              description: 'successful operation',
              schema: {
                type: 'object',
                additionalProperties: { type: 'integer', format: 'int32' },
              },
            },
          },
          security: [{ api_key: [] }],
        },
      },
      '/user/createWithArray': {
        post: {
          tags: ['user'],
          summary: 'Creates list of users with given input array',
          description: '',
          operationId: 'createUsersWithArrayInput',
          consumes: ['application/json'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              in: 'body',
              name: 'body',
              description: 'List of user object',
              required: true,
              schema: { type: 'array', items: { $ref: '#/definitions/User' } },
            },
          ],
          responses: { default: { description: 'successful operation' } },
        },
      },
      '/user/createWithList': {
        post: {
          tags: ['user'],
          summary: 'Creates list of users with given input array',
          description: '',
          operationId: 'createUsersWithListInput',
          consumes: ['application/json'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              in: 'body',
              name: 'body',
              description: 'List of user object',
              required: true,
              schema: { type: 'array', items: { $ref: '#/definitions/User' } },
            },
          ],
          responses: { default: { description: 'successful operation' } },
        },
      },
      '/user/{username}': {
        get: {
          tags: ['user'],
          summary: 'Get user by user name',
          description: '',
          operationId: 'getUserByName',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'username',
              in: 'path',
              description:
                'The name that needs to be fetched. Use user1 for testing. ',
              required: true,
              type: 'string',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              schema: { $ref: '#/definitions/User' },
            },
            '400': { description: 'Invalid username supplied' },
            '404': { description: 'User not found' },
          },
        },
        put: {
          tags: ['user'],
          summary: 'Updated user',
          description: 'This can only be done by the logged in user.',
          operationId: 'updateUser',
          consumes: ['application/json'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'username',
              in: 'path',
              description: 'name that need to be updated',
              required: true,
              type: 'string',
            },
            {
              in: 'body',
              name: 'body',
              description: 'Updated user object',
              required: true,
              schema: { $ref: '#/definitions/User' },
            },
          ],
          responses: {
            '400': { description: 'Invalid user supplied' },
            '404': { description: 'User not found' },
          },
        },
        delete: {
          tags: ['user'],
          summary: 'Delete user',
          description: 'This can only be done by the logged in user.',
          operationId: 'deleteUser',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'username',
              in: 'path',
              description: 'The name that needs to be deleted',
              required: true,
              type: 'string',
            },
          ],
          responses: {
            '400': { description: 'Invalid username supplied' },
            '404': { description: 'User not found' },
          },
        },
      },
      '/user/login': {
        get: {
          tags: ['user'],
          summary: 'Logs user into the system',
          description: '',
          operationId: 'loginUser',
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              name: 'username',
              in: 'query',
              description: 'The user name for login',
              required: true,
              type: 'string',
            },
            {
              name: 'password',
              in: 'query',
              description: 'The password for login in clear text',
              required: true,
              type: 'string',
            },
          ],
          responses: {
            '200': {
              description: 'successful operation',
              headers: {
                'X-Expires-After': {
                  type: 'string',
                  format: 'date-time',
                  description: 'date in UTC when token expires',
                },
                'X-Rate-Limit': {
                  type: 'integer',
                  format: 'int32',
                  description: 'calls per hour allowed by the user',
                },
              },
              schema: { type: 'string' },
            },
            '400': { description: 'Invalid username/password supplied' },
          },
        },
      },
      '/user/logout': {
        get: {
          tags: ['user'],
          summary: 'Logs out current logged in user session',
          description: '',
          operationId: 'logoutUser',
          produces: ['application/json', 'application/xml'],
          parameters: [],
          responses: { default: { description: 'successful operation' } },
        },
      },
      '/user': {
        post: {
          tags: ['user'],
          summary: 'Create user',
          description: 'This can only be done by the logged in user.',
          operationId: 'createUser',
          consumes: ['application/json'],
          produces: ['application/json', 'application/xml'],
          parameters: [
            {
              in: 'body',
              name: 'body',
              description: 'Created user object',
              required: true,
              schema: { $ref: '#/definitions/User' },
            },
          ],
          responses: { default: { description: 'successful operation' } },
        },
      },
    },
    securityDefinitions: {
      api_key: { type: 'apiKey', name: 'api_key', in: 'header' },
      petstore_auth: {
        type: 'oauth2',
        authorizationUrl: 'https://petstore.swagger.io/oauth/authorize',
        flow: 'implicit',
        scopes: {
          'read:pets': 'read your pets',
          'write:pets': 'modify pets in your account',
        },
      },
    },
    definitions: {
      ApiResponse: {
        type: 'object',
        properties: {
          code: { type: 'integer', format: 'int32' },
          type: { type: 'string' },
          message: { type: 'string' },
        },
      },
      Category: {
        type: 'object',
        properties: {
          id: { type: 'integer', format: 'int64' },
          name: { type: 'string' },
        },
        xml: { name: 'Category' },
      },
      Pet: {
        type: 'object',
        required: ['name', 'photoUrls'],
        properties: {
          id: { type: 'integer', format: 'int64' },
          category: { $ref: '#/definitions/Category' },
          name: { type: 'string', example: 'doggie' },
          photoUrls: {
            type: 'array',
            xml: { wrapped: true },
            items: { type: 'string', xml: { name: 'photoUrl' } },
          },
          tags: {
            type: 'array',
            xml: { wrapped: true },
            items: { xml: { name: 'tag' }, $ref: '#/definitions/Tag' },
          },
          status: {
            type: 'string',
            description: 'pet status in the store',
            enum: ['available', 'pending', 'sold'],
          },
        },
        xml: { name: 'Pet' },
      },
      Tag: {
        type: 'object',
        properties: {
          id: { type: 'integer', format: 'int64' },
          name: { type: 'string' },
        },
        xml: { name: 'Tag' },
      },
      Order: {
        type: 'object',
        properties: {
          id: { type: 'integer', format: 'int64' },
          petId: { type: 'integer', format: 'int64' },
          quantity: { type: 'integer', format: 'int32' },
          shipDate: { type: 'string', format: 'date-time' },
          status: {
            type: 'string',
            description: 'Order Status',
            enum: ['placed', 'approved', 'delivered'],
          },
          complete: { type: 'boolean' },
        },
        xml: { name: 'Order' },
      },
      User: {
        type: 'object',
        properties: {
          id: { type: 'integer', format: 'int64' },
          username: { type: 'string' },
          firstName: { type: 'string' },
          lastName: { type: 'string' },
          email: { type: 'string' },
          password: { type: 'string' },
          phone: { type: 'string' },
          userStatus: {
            type: 'integer',
            format: 'int32',
            description: 'User Status',
          },
        },
        xml: { name: 'User' },
      },
    },
    externalDocs: {
      description: 'Find out more about Swagger',
      url: 'http://swagger.io',
    },
  }),
}

const nodeFetch = async (_url: string) => {
  return {
    json: async () => {
      const [url, query] = _url.split('?')
      const { token } = Object.fromEntries(new URLSearchParams(query).entries())
      const path = Object.keys(mockData).find(path => url.endsWith(path))
      const mockRes = (path && mockData[path]()) || {}
      if (path!.endsWith('/api/plugin/export')) {
        exportCount++
        ;(mockRes as any[]).forEach(group => {
          ;(group.list as any[]).forEach(item => {
            item.path = `/__${token}__${item.path}`
          })
        })
      }
      if (path!.endsWith('/api/project/get') && token === 'with-basepath') {
        mockRes.data.basepath = '/i-am-basepath'
      }
      return mockRes
    },
  }
}

nodeFetch.resetExportCount = () => (exportCount = 0)
nodeFetch.getExportCount = () => exportCount

module.exports = nodeFetch
